package com.wjl.shop.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wjl.shop.dao.EnclosureDao;
import com.wjl.shop.entity.Enclosure;
import com.wjl.shop.entity.StockOrder;
import com.wjl.shop.dao.StockOrderDao;
import com.wjl.shop.dao.ProductDao;
import com.wjl.shop.entity.Product;
import com.wjl.shop.entity.SumOrder;
import com.wjl.shop.service.StockOrderService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ResourceUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import javax.servlet.http.HttpServletRequest;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.sql.Timestamp;
import java.util.*;


/**
 * 备货订单表(StockOrder)表服务实现类
 *
 * @author makejava
 * @since 2021-10-06 14:43:21
 */
@Service("stockOrderService")
public class StockOrderServiceImpl implements StockOrderService {
    final public static  String SPLIT_CHAR="、";
    @Resource
    private StockOrderDao stockOrderDao;
    @Resource
    private EnclosureDao enclosureDao;

    @Resource
    private ProductDao productDao;

    /**
     * 通过ID查询单条数据
     *
     * @param stockOrder 主键
     * @return 实例对象
     */
    @Override
    public Map<String,Object> queryByOrder(StockOrder stockOrder) {
        return this.stockOrderDao.queryByOrder(stockOrder);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<StockOrder> queryAllByLimit(int offset, int limit) {
        return this.stockOrderDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param stockOrder 实例对象
     * @return 实例对象
     */
    @Override
    public StockOrder insert(StockOrder stockOrder) {
        this.stockOrderDao.insert(stockOrder);
        return stockOrder;
    }

    @Override
    public Map<String, Object> update(StockOrder stockOrder) {
        int update = stockOrderDao.update(stockOrder);
        Map<String,Object> map=new HashMap<>();
        map.put("state","ok");
        map.put("data",update);
        return map;
    }


    /**
     * 新增订单
     *
     *
     * @return 实例对象
     */
    @Override
    @Transactional
    public Map<String,Object> addOrder(HttpServletRequest request) {

        Double orderPrice = 0.0;
        Double totalVolume = 0.0;
        Double needMoney=0.0;
        Map<String, Object> map = new HashMap<>();
        Integer proNum=0;
        if (request.getParameter("proNum")!=null && request.getParameter("proNum")!=""){
            proNum = Integer.valueOf(request.getParameter("proNum"));
        }else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "产品数量不能为0");
            return map;
        }

        List<String> proCodes = new ArrayList<>();
        if (request.getParameter("proCode")!=null && request.getParameter("proCode")!=""){
            proCodes.add(request.getParameter("proCode"));
        }else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "产品编号不能为空");
            return map;
        }


        List<Product> products = productDao.queryByProCode(proCodes);
        for (Product product : products) {
            orderPrice = proNum * product.getBasePrice();
            totalVolume = proNum * product.getVolume();
            needMoney=orderPrice*0.3;
        }

        StockOrder stockOrder = new StockOrder();
        if (request.getParameter("dealerCode") != null && request.getParameter("dealerCode") !="") {
            stockOrder.setDealerCode(request.getParameter("dealerCode"));
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "经销商编码不能为空");
            return map;
        }

        if (request.getParameter("storageInCode") != null && request.getParameter("storageInCode") !="") {
            stockOrder.setStorageInCode(request.getParameter("storageInCode"));
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "入货仓库不能为空");
            return map;
        }
        if (request.getParameter("storageOutCode") != null && request.getParameter("storageOutCode")!="") {
            stockOrder.setStorageOutCode(request.getParameter("storageOutCode"));
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "出货仓库不能为空");
            return map;
        }

        stockOrder.setRemark(request.getParameter("remark"));

        if (request.getParameter("proCode") != null && request.getParameter("proCode") !="") {
            stockOrder.setProCode(request.getParameter("proCode"));
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "产品编号不能为空");
            return map;
        }

        if (request.getParameter("proNum") != null && request.getParameter("proNum") !="") {
            stockOrder.setProNum(Integer.valueOf(request.getParameter("proNum")));
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "产品数量不能为空");
            return map;
        }

        if (request.getParameter("requireDateFrom") != null && request.getParameter("requireDateFrom")!="") {
            stockOrder.setRequireDateFrom(strToDate(request.getParameter("requireDateFrom")));
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "起始日期不能为空");
            return map;
        }

        if (request.getParameter("requireDateTo") != null && request.getParameter("requireDateTo") !="") {
            if (stockOrder.getRequireDateFrom().before(strToDate(request.getParameter("requireDateTo")))){
                stockOrder.setRequireDateTo(strToDate(request.getParameter("requireDateTo")));
            }else {
                map.put("message", "提交失败");
                map.put("code", 0);
                map.put("data","起始日期必须早于截止日期！");
                return map;
            }
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "截止日期不能为空");
            return map;
        }

        if (request.getParameter("sendWay") != null && request.getParameter("sendWay") !="") {
            stockOrder.setSendWay(request.getParameter("sendWay"));
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "运货方式不能为空");
            return map;
        }
        stockOrder.setOrderPrice(orderPrice);
        stockOrder.setTotalVolume(totalVolume);
        stockOrder.setOrderType(0);
        stockOrder.setSubmitDate(new Date());
        stockOrder.setOrderCode("BH" + System.currentTimeMillis());
        stockOrder.setStateCode(2);
        stockOrder.setIsPaid(0.0);
        stockOrder.setNeededMoney(needMoney);
        int rows = stockOrderDao.addOrder(stockOrder);
        map = new HashMap<>();
        if (rows >= 1) {
            map.put("message", "提交成功");
            map.put("code", 0);
            map.put("data", rows);
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", rows);
        }
        return map;
    }


    /**
     * 保存订单
     *
     * @param request
     * @return
     */
    @Override
    @Transactional
    public Map<String, Object> saveOrder(HttpServletRequest request) {
        Double orderPrice = 0.0;
        Double totalVolume = 0.0;
        Double needMoney=0.0;
        Map<String, Object> map = new HashMap<>();
        Integer proNum=0;
        if(request.getParameter("proNum")!=null && request.getParameter("proNum")!=""){
            proNum = Integer.valueOf(request.getParameter("proNum"));
        }

        List<String> proCodes = new ArrayList<>();
        if (request.getParameter("proCode")!=null && request.getParameter("proCode")!=""){
            proCodes.add(request.getParameter("proCode"));
        }else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "产品编号不能为空");
            return map;
        }
        List<Product> products = productDao.queryByProCode(proCodes);
        for (Product product : products) {
            orderPrice = proNum * product.getBasePrice();
            totalVolume = proNum * product.getVolume();
            needMoney=orderPrice*0.3;
        }

        StockOrder stockOrder = new StockOrder();
        stockOrder.setDealerCode(request.getParameter("dealerCode"));
        stockOrder.setStorageInCode(request.getParameter("storageInCode"));
        stockOrder.setStorageOutCode(request.getParameter("storageOutCode"));
        stockOrder.setRemark(request.getParameter("remark"));
        stockOrder.setProCode(request.getParameter("proCode"));
        if (request.getParameter("proNum")!=null && request.getParameter("proNum")!=""){
            stockOrder.setProNum(Integer.valueOf(request.getParameter("proNum")));
        }else {
            stockOrder.setProNum(0);
        }

        if (request.getParameter("requireDateFrom") != null && request.getParameter("requireDateFrom")!="") {
            stockOrder.setRequireDateFrom(strToDate(request.getParameter("requireDateFrom")));
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "起始日期不能为空");
            return map;
        }

        if (request.getParameter("requireDateTo") != null && request.getParameter("requireDateTo")!="") {
            if (stockOrder.getRequireDateFrom().before(strToDate(request.getParameter("requireDateTo")))){
                stockOrder.setRequireDateTo(strToDate(request.getParameter("requireDateTo")));
            }else {
                map.put("message", "提交失败");
                map.put("code", 0);
                map.put("data","起始日期必须早于截止日期！");
                return map;
            }
        } else {
            map.put("message", "提交失败");
            map.put("code", 0);
            map.put("data", "截止日期不能为空");
            return map;
        }

        stockOrder.setSendWay(request.getParameter("sendWay"));
        stockOrder.setOrderPrice(orderPrice);
        stockOrder.setTotalVolume(totalVolume);
        stockOrder.setOrderType(0);
        stockOrder.setSubmitDate(new Date());
        stockOrder.setOrderCode("BH" + System.currentTimeMillis());
        stockOrder.setStateCode(0);
        stockOrder.setNeededMoney(needMoney);
        stockOrder.setIsPaid(0.0);
        int rows = stockOrderDao.addOrder(stockOrder);
        map = new HashMap<>();
        if (rows >= 1) {
            map.put("message", "保存成功");
            map.put("code", 0);
            map.put("data", rows);
        } else {
            map.put("message", "保存失败");
            map.put("code", 0);
            map.put("data", rows);
        }
        return map;
    }


    /**
     * 审核是否通过（更改审核状态）
     *
     *
     * @return 实例对象
     */
    @Override
    @Transactional
    public Map<String, Object> updateInfo(List<String> list,StockOrder stockOrder) {
        List<Map<String, Object>> list2 = this.stockOrderDao.queryListByStockOrderCodes(list);
        //若待缴纳保金≥需缴纳保金时，则订单为待上传附件状态；若待缴纳保金<需缴纳保金时，则订单状态为待缴纳保金状态
        for(int i=0;i<list2.size();i++){
            Map<String,Object> map2 = list2.get(i);
            Object status_name = map2.get("stateCode");
            Object order_code = map2.get("orderCode");
            if(status_name.toString().equals("2")){
                System.out.println("======="+status_name.toString());
                Date date = new Date();
                Timestamp timestamp = new Timestamp(date.getTime());
                StockOrder stockOrder1 = new StockOrder();
                stockOrder1.setReviewTime(timestamp);
                stockOrder1.setStateCode(7);
                stockOrder1.setOrderCode(order_code.toString());
                stockOrder1.setViewUser(stockOrder.getViewUser());

                this.stockOrderDao.update(stockOrder1);
                BigDecimal isPaid = (BigDecimal)map2.get("isPaid");
                BigDecimal neededMoney = (BigDecimal)map2.get("neededMoney");
                if(isPaid==null||neededMoney==null){
                    isPaid=BigDecimal.ZERO;
                    neededMoney=BigDecimal.ZERO;
                }
                if (isPaid.compareTo(neededMoney)<0){
                    StockOrder stockOrder2=new StockOrder();
                    stockOrder2.setStateCode(8);
                    stockOrder2.setOrderCode(order_code.toString());
                    this.stockOrderDao.update(stockOrder2);
                }
            }
        }

        Map<String, Object> map = new HashMap<>();
        map.put("code", 1);
        map.put("message", "审核完成");
        return map;
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.stockOrderDao.deleteById(id) > 0;
    }

    /**
     * 待审核列表
     * @param stockOrder
     * @return
     */
    @Cacheable(cacheNames="stockOrder",key="#stockOrder")
    @Override
    public Map<String, Object> serchInfo(StockOrder stockOrder) {
        HashMap<String, Object> map = new HashMap<>();
        //进行分页设置
        PageHelper.startPage( stockOrder.getPage(), stockOrder.getRows() );
        //获取数据访问层的查询信息
        List<Map<String, Object>> list = this.stockOrderDao.serchInfo(stockOrder);
        //进行分页处理
        PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
        // 返回分页结果
        map.put( "total", pageInfo.getTotal() );
        map.put( "rows", pageInfo.getSize() );
        map.put("data",list);
        map.put("message","审核完成");
        return map;
    }

    /**
     * 复审列表
     * @param stockOrder
     * @return
     */
    @Override
    @Transactional
    public Map<String, Object> review(StockOrder stockOrder) {
        List<Map<String, Object>> list = this.stockOrderDao.serchInfo(new StockOrder());
        for(Map<String,Object> map:list){
            Object status_name = map.get("status_name");
            Object order_code = map.get("order_code");
            if(status_name.equals("待复核")){
                for(String code:stockOrder.getOrderCodes()){
                    if(code.equals(order_code)){
                        Date date = new Date();
                        Timestamp timestamp = new Timestamp(date.getTime());
                        StockOrder stockOrder1 = new StockOrder();
                        stockOrder1.setReviewTime(timestamp);
                        stockOrder1.setStateCode(5);
                        stockOrder1.setOrderCodes(new String[]{code});
                        stockOrder1.setReviewUser(stockOrder.getReviewUser());
                        int update = this.stockOrderDao.updateInfo(stockOrder1);
                        break;
                    }
                }
            }

        }

        Map<String,Object> map = new HashMap<>();
        map.put("code",1);
        map.put("message","复审结束");

        return map;
    }

    /**
     * 驳回理由
     * @param stockOrder
     * @return
     */
    @Override
    @Transactional
    public Map<String, Object> updatenot(StockOrder stockOrder) {
        List<Map<String, Object>> list = this.stockOrderDao.serchInfo(stockOrder);

        for(Map<String,Object> map:list){

            Object order_code = map.get("order_code");
            Object status_name = map.get("status_name");
            if(status_name.equals("待审核")||status_name.equals("待复核")){
                for(String code:stockOrder.getOrderCodes()){
                    if(code.equals(order_code)){
                        Date date = new Date();
                        Timestamp timestamp = new Timestamp(date.getTime());
                        StockOrder stockOrder1 = new StockOrder();
                        stockOrder1.setReviewTime(timestamp);
                        stockOrder1.setStateCode(3);
                        stockOrder1.setOrderCodes(new String[]{code});
                        stockOrder1.setRejectReason(stockOrder.getRejectReason());
                        int update = this.stockOrderDao.updateInfo(stockOrder1);
                        break;
                    }
                }

            }
        }

        Map<String,Object> map = new HashMap<>();
        map.put("code",1);
        map.put("message","审核已驳回");

        return map;
    }
    /**
     * 提交订单
     * */
    @Override
    public Map<String, Object> commitOrder(List<String> orderCodes) {
        List<Map<String, Object>> ls = stockOrderDao.queryListByStockOrderCodes(orderCodes);
        System.out.println(ls);
        Map<String,Object> map1=new HashMap<>();
        for (int i=0;i<ls.size();i++){
            Map<String,Object> map=ls.get(i);
            System.out.println(map.get("stateCode"));
            System.out.println(map.get("stateCode").toString());
            if (map.get("stateCode").toString().equals("0")&&map.get("orderCode")!=null&&map.get("dealerCode")!=null&&
            map.get("proCode")!=null){
                StockOrder stockOrder=new StockOrder();
                stockOrder.setOrderCode(ls.get(i).get("orderCode").toString());
                stockOrder.setStateCode(2);
                int update = stockOrderDao.update(stockOrder);
                map1.put("code",1);
                map1.put("message","提交成功");
                map1.put("更新条数",update);
            }else {
                map1.put("code",0);
                map1.put("message","信息不全");
            }
        }
        return map1;
    }



    /**
     * 查看订单
     * @param stockOrder
     * @return
     */
    @Override
    @Cacheable(cacheNames = "stockOrder", key = "#stockOrder")
    public Map<String, Object> selectOrder(StockOrder stockOrder) {
        List<Map<String,Object>> list2=stockOrderDao.selectOrder(stockOrder);
        double totalPrice = 0.00;
        double totalVolume = 0.00;
        for (int i=0;i<list2.size();i++){
            Map<String,Object> map2=list2.get(i);
            totalPrice += Double.valueOf(map2.get("order_price").toString());
            totalVolume += Double.valueOf(map2.get("total_volume").toString());
        }
        PageHelper.startPage(stockOrder.getPage(), stockOrder.getRows());
        List<Map<String, Object>> map = stockOrderDao.selectOrder(stockOrder);
        Map<String, Object> list = new HashMap<>();
        list.put("total_price", totalPrice);
        list.put("total_volume", totalVolume);
        PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(map);
        list.put("total", pageInfo.getTotal());
        list.put("rows", pageInfo.getSize());
        list.put("data",map);
        list.put("state","ok");
        list.put("message","成功");
        return list;
    }

    /**
     * 日期格式转换方法，字符串转日期
     *
     * @param datestr
     * @return
     */
    public Date strToDate(String datestr){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date date=sdf.parse(datestr);
            return date;
        } catch (ParseException e) {
            return null;
        }
    }

    /**
     * 合并备货订单
     * @param codes 订单列表
     * @return
     */
    @Override
    @Cacheable(cacheNames = "sumStockOrders",key = "#codes")
    public Map<String, Object> sumOrdersByCodes(List<String> codes) {
        final HashMap<String, Object> map = new HashMap<>();
        try {
            final List<Map<String, Object>> list = stockOrderDao.queryListByStockOrderCodes(codes);
            final List<Map<String, Object>> maps = new ArrayList<>();
            if(list.size()<=0){throw new RuntimeException();}
            final HashMap<String, SumOrder> sumOrderHashMap = new HashMap<>();
            while (list.size()>0){
                Map<String, Object> data = list.get(0);
                String proCode = (String)data.get("proCode");
                if(sumOrderHashMap.containsKey(proCode)){
                    final SumOrder sumOrder = sumOrderHashMap.get(proCode);
                    sumOrder.setOrderCode(sumOrder.getOrderCode()+SPLIT_CHAR+data.get("orderCode"));
                    sumOrder.setProTotalNum(sumOrder.getProTotalNum()+(Integer)data.get("proNum"));
                    final double proTotalVolume = (Double) sumOrder.getProTotalVolume();
                    final Double aDouble = (Double) data.get("totalVolume");
                    sumOrder.setProTotalVolume(proTotalVolume+aDouble);
                    final BigDecimal isPaid = (BigDecimal) data.get("isPaid");
                    sumOrder.setPaid(sumOrder.getPaid()+new Double(isPaid.toString()));
                    final BigDecimal orderPrice = (BigDecimal) data.get("orderPrice");
                    sumOrder.setTotalPrice(sumOrder.getTotalPrice()+new Double(orderPrice.toString()));
                }else {
                    final SumOrder sumOrder = new SumOrder();
                    sumOrder.setStartTime((Date) data.get("requireDateFrom"));
                    sumOrder.setEndTime((Date) data.get("requireDateTo"));
                    Date date = new Date();
                    sumOrder.setSumOrderCode("HZ"+date.getTime());
                    sumOrder.setSumOrderDate(date);
                    sumOrder.setOrderCode((String) data.get("orderCode"));
                    sumOrder.setProCode(proCode);
                    sumOrder.setStorageInCode((String) data.get("storageInCode"));
                    sumOrder.setStorageOutCode((String) data.get("storageOutCode"));
                    final BigDecimal isPaid = (BigDecimal) data.get("isPaid");
                    sumOrder.setPaid(new Double(isPaid.toString()));
                    sumOrder.setProTotalVolume(data.get("totalVolume"));
                    sumOrder.setProTotalNum((Integer) data.get("proNum"));
                    sumOrder.setSendMethod((String) data.get("sendWay"));
                    final BigDecimal orderPrice = (BigDecimal) data.get("orderPrice");
                    sumOrder.setTotalPrice(new Double(orderPrice.toString()));

                    sumOrderHashMap.put(proCode,sumOrder);
                }
                maps.add(data);
                list.remove(0);
            }
            map.put("status","ok");
            map.put("message","合并成功!");
            map.put("data",sumOrderHashMap.values());
            map.put("order",maps);
        }catch (Exception e){
            map.clear();
            map.put("status","fail");
            map.put("message","合并失败.");
            map.put("data",e.toString());
            e.printStackTrace();
            return map;
        }
        return map;
    }

    /**
     * 上传文件
     */
    @Override
    @Transactional
    public Map<String, Object> FileUpdate(StockOrder stockOrder, MultipartFile file) throws IOException {
        Map<String, Object> map1 = queryByOrder(stockOrder);
        Map<String, Object> map = new HashMap<>();
        System.out.println(!Objects.isNull(map1));

        if (!Objects.isNull(map1)&&map1.get("state_code").toString().equals("7")){
            //取得当前上传文件的文件名称
            String originalFilename = file.getOriginalFilename();
            //transferTo是保存文件，参数就是要保存到的目录和名字
            File path = new File(ResourceUtils.getURL("classpath:").getPath());
            System.out.println(path);
            File upload = new File(path.getAbsoluteFile(), "upload");
            System.out.println(upload.getAbsolutePath());
            if (!upload.exists()) {
                upload.mkdirs();
            }
            String suffer = originalFilename.substring(originalFilename.lastIndexOf("."));
            UUID uuid = UUID.randomUUID();
            String newName = uuid + suffer;
            file.transferTo(new File(upload, newName));
            System.out.println("文件类型：" + file.getContentType());
            System.out.println("原文件名：" + originalFilename);
            System.out.println("是否为空：" + file.isEmpty());
            System.out.println("文件大小：" + file.getSize());
            Enclosure enclosure = new Enclosure();
            enclosure.setOrderCode(stockOrder.getOrderCode());
            enclosure.setSourceName(newName);
            enclosure.setResourceOldName(originalFilename);
            enclosureDao.insert(enclosure);
            map.put("code", 1);
            map.put("message", "上传成功");
            map.put("data",upload);
            stockOrder.setStateCode(4);
            stockOrderDao.update(stockOrder);
        }else {
            map.put("code",0);
            map.put("message","上传失败");
        }

        return map;
    }
    /**
     * 取消订单
     *
     * */
    @Override
    @Transactional
    public Map<String, Object> canCel(List<String> list) {
        List<Map<String, Object>> ls = stockOrderDao.queryListByStockOrderCodes(list);
        System.out.println(ls);
        Map<String,Object> map2=new HashMap<>();
        for (int i=0;i<ls.size();i++){
            Map<String,Object> map=ls.get(i);
            if (map.get("stateCode").toString().equals("0")||map.get("stateCode").toString().equals("2")||
                    map.get("stateCode").toString().equals("7")){
                StockOrder stockOrder=new StockOrder();
                stockOrder.setOrderCode(ls.get(i).get("orderCode").toString());
                stockOrder.setStateCode(11);
                int update = stockOrderDao.update(stockOrder);
                map2.put("code",1);
                map2.put("message","取消成功");
            }else{
                map2.put("code",0);
                map2.put("message","取消失败");
            }
        }
        return map2;
    }
    /**
     * 修改订单
     * */
    @Override
    public Map<String, Object> modifyOrder(StockOrder stockOrder) {
        List<Map<String, Object>> list = stockOrderDao.selectOrder(stockOrder);
        Map<String,Object> map2=new HashMap<>();
        for (int i=0;i<list.size();i++){
            Map<String,Object> map=list.get(i);
            if (map.get("status_name").toString().equals("未提交")){
                int update = stockOrderDao.update(stockOrder);
                map2.put("code",1);
                map2.put("message","修改成功");
            }else{
                map2.put("code",0);
                map2.put("message","修改失败");
            }
        }
        map2.put("data",list);
        return map2;
    }
}
